//v.2.0 build 90722
/*
 Copyright DHTMLX LTD. http://www.dhtmlx.com
 You allowed to use this component or parts of it under GPL terms
 To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
 */
/*$Rev$*/
scheduler._props = {};
scheduler.createUnitsView = function(B, E, D){

    scheduler.date[B + "_start"] = scheduler.date.day_start;
    scheduler.templates[B + "_date"] = function(F){
        return scheduler.templates.day_date(F)
    };
    scheduler.templates[B + "_scale_date"] = function(F){
        return scheduler.templates.day_scale_date(F)
    };
    scheduler.templates[B + "_scale_date"] = function(F){
        return D[Math.floor((F.valueOf() - scheduler._min_date.valueOf()) / (60 * 60 * 24 * 1000))].label
    };
    scheduler.date["add_" + B] = function(F, G){
        return scheduler.date.add(F, G, "day")
    };
    scheduler.date["get_" + B + "_end"] = function(F){
        return scheduler.date.add(F, D.length, "day")
    };
    var A = {};
    for (var C = 0; C < D.length; C++) {
        A[D[C].key] = C
    }
    scheduler._props[B] = {
        map_to: E,
        options: D,
        order: A
    }
};
 var sections 
 var i =0;
(function(){

    var C = function(I, G){
        if (I && typeof G[I.map_to] == "undefined") {
            var F = scheduler;
            var E = 24 * 60 * 60 * 1000;
            var H = Math.floor((G.end_date - F._min_date) / E);
            G.end_date = new Date(F.date.time_part(G.end_date) * 1000 + F._min_date.valueOf());
            G.start_date = new Date(F.date.time_part(G.start_date) * 1000 + F._min_date.valueOf());
            G[I.map_to] = I.options[H].key;
            return true
        }
    };
    var A = scheduler._reset_scale;
    scheduler._reset_scale = function(){
        var F = scheduler._props[this._mode];
        var E = A.apply(this, arguments);
        if (F) {
            this._max_date = this.date.add(this._min_date, 1, "day")
        }
        return E
    };
    var B = scheduler._get_event_sday;
    scheduler._get_event_sday = function(E){
        var F = scheduler._props[this._mode];
        if (F) {
            C(F, E);
            return F.order[E[F.map_to]]
        }
        return B.call(this, E)
    };
    var D = scheduler._mouse_coords;
    scheduler._mouse_coords = function(){
        var G = scheduler._props[this._mode];
        var F = D.apply(this, arguments);
        if (G) {
            var E = this._drag_event;
            if (this._drag_id) {
                E = this.getEvent(this._drag_id);
                this._drag_event.start_date = new Date()
            }
            E[G.map_to] = G.options[F.x].key;
            F.x = 0
        }
        return F
    };
    scheduler.attachEvent("onEventAdded", function(H, F){
        if (this._loading) {
            return true
        }
        for (var E in scheduler._props) {
            var G = scheduler._props[E];
            if (typeof F[G.map_to] == "undefined") {
                F[G.map_to] = G.options[0].key
            }
        }
        parent.DATA = scheduler._obj.children;
        return true
    });
    scheduler.attachEvent("onEventCreated", function(H, E){
        var G = scheduler._props[this._mode];
        var F = this.getEvent(H);
        this._mouse_coords(E);
        C(G, F);
        this.event_updated(F);
        return true
    })
})();
